package com.androidmvc.base;

import android.app.Application;

import com.androidmvc.base.network.http.okhttp.OkHttpFinal;
import com.androidmvc.base.network.http.okhttp.OkHttpFinalConfiguration;
import com.franmontiel.persistentcookiejar.ClearableCookieJar;
import com.franmontiel.persistentcookiejar.PersistentCookieJar;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;

/**
 * Created by jmh on 2017/3/24.
 */

public class UApplication extends Application {

    private static UApplication mApplication = null;
    public OkHttpFinalConfiguration.Builder builder;
    @Override
    public void onCreate() {
        super.onCreate();
        mApplication = this;
        ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(this));
        builder = new OkHttpFinalConfiguration.Builder();
        builder.setCookieJar(cookieJar);
        OkHttpFinal.getInstance().init(builder.build());
    }

    public static UApplication getInstance() {
        return mApplication;
    }
}
